﻿<?php 

$cc=new ccTell;
$cc-> type();
class ccTell{

			public function type(){

				switch ($_GET['type']) {
					case '1':
							echo self::getHeaders();
						break;
					
					default:
						# code...
						break;
				}
			}


			public function getCC(){


				$url='http://cc.qumei.com/TaskManage/GetCommunicateStatisticsList';

				$search=["ChannelID"=>-1,"IsTaskStatus"=>1,"IsDeleted"=>0,"FromDate"=>"2020-07-21","ToDate"=>"2020-07-23","IsCommunicateStatistics"=>1];

				$searchJson=json_encode($search);

				var_dump($searchJson);

				$params=['pageIndex'=>0,'searchJson'=>$searchJson];

				$data=self::php_do_Url_GET($url,$params);

				return $data;


			}

			public function php_do_Url_GET($url,$params=[],$headers=[]){ //Get get

				$url = "{$url}?" . http_build_query ($params);
				echo $url;
				$ch = curl_init ();
				curl_setopt ( $ch, CURLOPT_URL, $url );
				curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
				curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
				curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
				//curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
				curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
				curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
				curl_setopt($ch, CURLOPT_SSLVERSION, false);
				curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

				$json_string = curl_exec ( $ch );

				$data = json_decode($json_string, true);

				var_dump(curl_error($ch));

				curl_close ( $ch );

				return $data;
		}

		public function getHeaders(){

			$token='2c1a8e0578a93f80d9cb38fa5183fe94a6f3072320d6242d7910eb8fcc91757e';
			$username="webuser";
            $password="Qumei1993";
            $timestamp='\''.time().'\'';

            $sign = md5($username.",".$password.",".$timestamp);

            $headers = array(
                "Content-Type"=>"application/json",
                "Authorization"=>"$token", //Bearer 
                "username"=>$username,
                "password"=>$password,
                "timestamp"=>$timestamp,
                "sign"=> $sign
            );

            return json_encode($headers);
		}




}




 ?>